#ifndef MOTOR_H
#define MOTOR_H

#include "zf_common_headfile.h"

#define motorL_pwm PWM2_MODULE0_CHB_C7
#define motorL_turn C6

#define motorC_pwm PWM2_MODULE3_CHB_D3
#define motorC_turn D2

#define motorR_pwm PWM2_MODULE2_CHB_C11
#define motorR_turn C10

#define pid_limit 6000

typedef struct motor
{
	int target_speed;
	int duty;
	int encoder_speed;
	int encoder_raw;
	int32 total_encoder;
}motor;

extern struct motor motor_l;
extern struct motor motor_r;
 

void Final_Motor_Control(int speed,float k,int limit);
void car_start(void);
void Speed_Set(pwm_channel_enum pin1,gpio_pin_enum pin2,int speed,uint8 just,uint8 lose);
void Motor_Control(int Speed_L,int Speed_R);

void motor_Init();
void motorL_SetSpeed(int pwm);
void motorC_SetSpeed(int pwm);
void motorR_SetSpeed(int pwm);

void Encoder_Init(void);
void Encoder_Data_Get(void);

void zhixian(void);

#endif 

